package lesson7;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Demo2 {
    public static void main(String[] args) {
        //获取当前时间
        Date date1 = new Date();
        System.out.println(date1.getYear()+1900);
        System.out.println(date1.getMonth()+1);
        System.out.println(date1.getDate());
        System.out.println(date1.getDay());
        System.out.println(date1.getHours());
        System.out.println(date1.getMinutes());
        System.out.println(date1.getSeconds());
        System.out.println(date1);
        //yyyy-MM-dd HH:mm:ss SSS
        //日期格式化
        SimpleDateFormat df = new SimpleDateFormat("yyyy/MM---天---dd HH时mm分ss秒");
        String str = df.format(date1);
        System.out.println(str);

//        Date date2 = new Date("2021/03/08 17:15");
//        System.out.println(date2.getYear()+1900);

    }
}
